<?php
	//转码
function file_utf8($filepath){
    $f_contents= file_get_contents($filepath);
     
    $encoding = mb_detect_encoding($f_contents, array('GB2312','GBK','UTF-16','UCS-2','UTF-8','BIG5','ASCII'));
 
    $content_u="";
    $handle=fopen($filepath,"r");
    if ($handle){
        while (!feof($handle)) {
            $buffer= fgets($handle);
            if ($encoding != false) {
                if (mb_detect_encoding($buffer)!='UTF-8'){
                    $buffer = iconv($encoding, 'UTF-8', $buffer);
                }
            }else{
                    $buffer = mb_convert_encoding ( $buffer, 'UTF-8','Unicode');
            }
            $content_u.=$buffer;
        }
    fclose($handle);
        
    }
	return $content_u;
}